package com.gange.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gange.entity.User;
import com.gange.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author gange
 * @since 2022-11-04
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;
    @GetMapping("/selectOne/{id}")
    public User selectById(@PathVariable("id") int id){
        return userService.getById(id);
    }
    @GetMapping("/selectName/{name}")
    public List<User> selectByName(@PathVariable("name") String name){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.like("name",name);
        return userService.list(wrapper);
    }
}

